/**
 * @mbggenerated
 * @author wujian
 */
package bearworker.zxl.dao.mapper;

import bearworker.zxl.entity.DeliveryPreOrder;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface DeliveryPreOrderMapper {
    /* @mbggenerated */
    @Delete({
        "delete from delivery_pre_order",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /* @mbggenerated */
    @Insert({
        "insert into delivery_pre_order (sender_id, recipients_id, ",
        "package_kilo, original_price, ",
        "create_time)",
        "values (#{senderId,jdbcType=INTEGER}, #{recipientsId,jdbcType=INTEGER}, ",
        "#{packageKilo,jdbcType=DOUBLE}, #{originalPrice,jdbcType=INTEGER}, ",
        "#{createTime,jdbcType=TIMESTAMP})"
    })
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insert(DeliveryPreOrder record);

    /* @mbggenerated */
    @InsertProvider(type=DeliveryPreOrderSqlProvider.class, method="insertSelective")
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insertSelective(DeliveryPreOrder record);

    /* @mbggenerated */
    @Select({
        "select",
        "id, sender_id, recipients_id, package_kilo, original_price, create_time",
        "from delivery_pre_order",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="sender_id", property="senderId", jdbcType=JdbcType.INTEGER),
        @Result(column="recipients_id", property="recipientsId", jdbcType=JdbcType.INTEGER),
        @Result(column="package_kilo", property="packageKilo", jdbcType=JdbcType.DOUBLE),
        @Result(column="original_price", property="originalPrice", jdbcType=JdbcType.INTEGER),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    DeliveryPreOrder selectByPrimaryKey(Integer id);

    /* @mbggenerated */
    @UpdateProvider(type=DeliveryPreOrderSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(DeliveryPreOrder record);

    /* @mbggenerated */
    @Update({
        "update delivery_pre_order",
        "set sender_id = #{senderId,jdbcType=INTEGER},",
          "recipients_id = #{recipientsId,jdbcType=INTEGER},",
          "package_kilo = #{packageKilo,jdbcType=DOUBLE},",
          "original_price = #{originalPrice,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(DeliveryPreOrder record);

    @Select({
            "select",
            "id, sender_id, recipients_id, package_kilo, original_price, create_time",
            "from delivery_pre_order",
            "where sender_id = #{0,jdbcType=INTEGER} and recipients_id = #{1,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="sender_id", property="senderId", jdbcType=JdbcType.INTEGER),
            @Result(column="recipients_id", property="recipientsId", jdbcType=JdbcType.INTEGER),
            @Result(column="package_kilo", property="packageKilo", jdbcType=JdbcType.DOUBLE),
            @Result(column="original_price", property="originalPrice", jdbcType=JdbcType.INTEGER),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    DeliveryPreOrder selectByWhere(Integer sender_id,Integer recipients_id);

    @Select({
            "select",
            "id, sender_id, recipients_id, package_kilo, original_price, create_time",
            "from delivery_pre_order",
            "where sender_id = #{0,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="sender_id", property="senderId", jdbcType=JdbcType.INTEGER),
            @Result(column="recipients_id", property="recipientsId", jdbcType=JdbcType.INTEGER),
            @Result(column="package_kilo", property="packageKilo", jdbcType=JdbcType.DOUBLE),
            @Result(column="original_price", property="originalPrice", jdbcType=JdbcType.INTEGER),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<DeliveryPreOrder> selectBySenderId(Integer senderId);
}